package com.feicheng.iou.controller.weChat;

import com.feicheng.iou.pojo.WxPayNotify;
import com.feicheng.iou.service.weChatService.WeChatPayNotifyService;
import com.feicheng.iou.weChatSdk.WXPayUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

//import com.github.wxpay.sdk.WXPayUtil;

@RestController
@Slf4j
public class WeChatPayNotifyController {

    @Autowired
    private WeChatPayNotifyService weChatPayNotifyService;

    /**
     * @param param  微信原样返回的同一下单参数,额外返回交易号等信息
     * @return
     * @description 支付结果通知回调
     * @throws Exception
     */
    @RequestMapping(value = "/success",produces = MediaType.TEXT_PLAIN_VALUE) //xml
    public String success(@RequestBody WxPayNotify param) throws Exception {
        log.info("success");
        return  weChatPayNotifyService.success(param);

    }

    @GetMapping("/")
    public String root() {
        return "Https";
    }

}
